package com.intellagric.controller.module.loganalyse;

import com.intellagric.common.pojo.LayuiDataGridResult;
import com.intellagric.common.pojo.ResponseMessage;
import com.intellagric.pojo.LogAnalyzeBusiness;
import com.intellagric.service.module.loganalyse.LogAnalyzeBusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * @Auther: zhy
 * @Date: 2019/5/11
 * @Description: 日志分析业务线管理
 */
@Controller
public class LogAnalyzeBusinessController {

    @Autowired
    private LogAnalyzeBusinessService logAnalyzeBusinessService;

    /**
     * 添加日志分析业务线信息
     * @Param logAnalyzeBusiness
     * @return ResponseMessage
     */
    @RequestMapping("/log/analysejob/business/add")
    @ResponseBody
    public ResponseMessage add(LogAnalyzeBusiness logAnalyzeBusiness) {
        logAnalyzeBusiness.setId(UUID.randomUUID().toString().replaceAll("-",""));
        logAnalyzeBusiness.setCreateTime(new Date());
        return logAnalyzeBusinessService.addLogAnalyzeBusiness(logAnalyzeBusiness);
    }


    /**
     * 删除日志分析业务线信息
     * @Param id
     * @return ResponseMessage
     */
    @RequestMapping("/log/analysejob/business/delete")
    @ResponseBody
    public ResponseMessage delete(String id) {
        return logAnalyzeBusinessService.deleteLogAnalyzeBusiness(id);
    }

    /**
     * 修改日志分析业务线信息
     * @Param logAnalyzeBusiness
     * @return ResponseMessage
     */
    @RequestMapping("/log/analysejob/business/edit")
    @ResponseBody
    public ResponseMessage edit(LogAnalyzeBusiness logAnalyzeBusiness) {
        return logAnalyzeBusinessService.editLogAnalyzeBusiness(logAnalyzeBusiness);
    }

    /**
     * 根据id查询日志分析业务线信息
     * @return LogAnalyzeBusiness
     */
    @RequestMapping("/log/analysejob/business/{id}")
    @ResponseBody
    public LogAnalyzeBusiness get(@PathVariable String id) {
        return logAnalyzeBusinessService.queryLogAnalyzeBusinessById(id);
    }


    /**
     * 查询日志分析业务线信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/log/analysejob/business/list")
    @ResponseBody
    public LayuiDataGridResult getList() {
        return logAnalyzeBusinessService.queryLogAnalyzeBusinessList();
    }

    /**
     * 分页查询日志分析业务线信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/log/analysejob/business/page")
    @ResponseBody
    public LayuiDataGridResult getPage(int page,int limit) {
        return logAnalyzeBusinessService.queryLogAnalyzeBusinessList();
    }


}
